package com.ruoyi.web.controller.zongdianpifa;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zongdianpifa.domain.ZongdianPifa;
import com.ruoyi.zongdianpifa.service.IZongdianPifaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 总店批发Controller
 *
 * @author ruoyi
 * @date 2023-05-24
 */
@Api(tags="总店批发管理")
@RestController
@RequestMapping("/system/pifa")
public class ZongdianPifaController extends BaseController
{
    @Autowired
    private IZongdianPifaService zongdianPifaService;

    /**
     * 查询总店批发列表
     */
    @ApiOperation("查询总店批发列表")
    @PreAuthorize("@ss.hasPermi('system:pifa:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZongdianPifa zongdianPifa)
    {
        startPage();
        List<ZongdianPifa> list = zongdianPifaService.selectZongdianPifaList(zongdianPifa);
        return getDataTable(list);
    }

    /**
     * 导出总店批发列表
     */
    @PreAuthorize("@ss.hasPermi('system:pifa:export')")
    @Log(title = "总店批发", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZongdianPifa zongdianPifa)
    {
        List<ZongdianPifa> list = zongdianPifaService.selectZongdianPifaList(zongdianPifa);
        ExcelUtil<ZongdianPifa> util = new ExcelUtil<ZongdianPifa>(ZongdianPifa.class);
        util.exportExcel(response, list, "总店批发数据");
    }

    /**
     * 获取总店批发详细信息
     */
    @ApiOperation("查询总店批发详细")
    @PreAuthorize("@ss.hasPermi('system:pifa:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zongdianPifaService.selectZongdianPifaById(id));
    }

    /**
     * 新增总店批发
     */
    @ApiOperation("新增总店批发")
    @PreAuthorize("@ss.hasPermi('system:pifa:add')")
    @Log(title = "总店批发", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZongdianPifa zongdianPifa)
    {
        return toAjax(zongdianPifaService.insertZongdianPifa(zongdianPifa));
    }

    /**
     * 修改总店批发
     */
    @ApiOperation("修改总店批发")
    @PreAuthorize("@ss.hasPermi('system:pifa:edit')")
    @Log(title = "总店批发", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZongdianPifa zongdianPifa)
    {
        return toAjax(zongdianPifaService.updateZongdianPifa(zongdianPifa));
    }

    /**
     * 删除总店批发
     */
    @ApiOperation("删除总店批发")
    @PreAuthorize("@ss.hasPermi('system:pifa:remove')")
    @Log(title = "总店批发", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zongdianPifaService.deleteZongdianPifaByIds(ids));
    }
}
